var globalStore,globalColumn,globalHeaderjson;
Ext.define('EUniversitySuperAdmin.controller.analyticboard', {
    extend: 'Ext.app.Controller',
    
    
    views: [
     		'analyticboard.gridboard',
     		'analyticboard.chartboard'
    		],
      refs : [{
        ref: 'analyticboardgridboard',
        selector: 'analyticboardgridboard',
        autoCreate: true,
        xtype: 'analyticboardgridboard'
    },{
        ref: 'chartboard',
        selector: 'chartboard',
        autoCreate: true,
        xtype: 'chartboard'
        	
    }
      
      ,{
        ref: 'tabsview',
        selector: 'tabsview'
    }],
    init: function() {
        this.control({
              'viewport > tabsview': {
                render: this.onPanelRendered
              },
              'analyticboardgridboard' :{
              	itemclick:this.LoadDataInForm
              }
          });
    } ,
    LoadDataInForm:function(grid, record){},
    onPanelRendered:function(){
    	
    	var me= this;
    	//chargement des columns de gride
    	Ext.Ajax.request({
    		url: 'pilotage/projectbord/dycolumnboard',
		    success: function(response1){
		    	globalColumn=response1.responseText;
		    	//chargement des data de store
		    	 Ext.Ajax.request({
		    		 url: 'pilotage/projectbord/loaddataboard',
		 		    success: function(response){
		 		    	globalStore=response.responseText;
		 		    	//chargement des donnée de fields de store
		 		    	Ext.Ajax.request({
		 		    		url: 'pilotage/projectbord/jsonstructerdataboard',
		 				    success: function(responseh){
		 				    	globalHeaderjson=responseh.responseText;
		 				    	// var viewer = me.getTabsview();
				 		    	 Ext.getCmp('tabs').add({
				 					        title: 'Analitic Board',
				 					        height:'300',
				 					       layout: {
				 					    	    type: 'hbox',
				 					    	    pack: 'start',
				 					    	    align: 'stretch'
				 					    	},
				 					        items:[
				 					        {	
				 					        	xtype: 'analyticboardgridboard',
				 					        	width:'50%',
				 					        	store :{
				 					       			fields:Ext.JSON.decode(responseh.responseText),
				 					       			data:Ext.JSON.decode(response.responseText)
				 					        	},
				 					        	columns : Ext.JSON.decode(response1.responseText),
				 					        	flex:1
				 						      },
				 						     {	
				 					        	xtype: 'chartboard',
				 					        	width:'50%',
				 					        	flex:2
					 						 }
				 								 
				 					        ],
				 					        closable:true
				 					    }).show();

		 				    }
		 		    	});
		 		    	
		 		    },
		 	        failure: function(response, opts) {}
		           
		 		});
		    },
	        failure: function(response, opts) {
          }
          
		});
    }
});